<% crlf=CHR(13)+CHR(10) SET CENTURY ON m_transid=orequest.form('thetransid') if isnull(m_transid) m_transid=orequest.querystring('t') endif calledon=nvl(orequest.querystring('calledon'),ttoc(dtot({//}))) theuser=[] &&orequest.querystring('user') pagetype=orequest.querystring('pw') ** pagetype=lower(transform(orequest.querystring('pw'))) * 80mm * * * * * *@page {size: | auto | [ || [ landscape | portrait ] ]} do case case [mix] $ pagetype isurdu=2 case [local] $ pagetype isurdu=1 OTHER isurdu=0 endcase do case case pagetype='pos' pagewidth='80mm' pageheight='3276mm' case pagetype='a4' pagewidth='8.3inch' pageheight='11.7inch' case pagetype='a5' pagewidth='5.8inch' pageheight='8.3inch' case pagetype='a6' pagewidth='4.1inch' pageheight='5.8inch' OTHER pagewidth='8.3inch' pageheight='11.7inch' endcase ** if isnull(m_transid) tsql=[select top 1 x.*,IIF(VAL(x.transid)=0,VAL(SUBSTR(x.transid,2)),VAL(x.transid)) AS VTR, ] tsql=tsql+[ padl(allt(x.transid),9) as ptransid, y.name as acname ] tsql=tsql+[ from ("]+dbclocation+'invoice.dbf'+[") x left join ("]+dbclocation+'accounts.dbf'+[") y ] tsql=tsql+[ on (x.customer=y.accountid) order by vtr desc, ptransid desc into cursor xtmpcur] else tsql=[select top 1 x.*,IIF(VAL(x.transid)=0,VAL(SUBSTR(x.transid,2)),VAL(x.transid)) AS VTR, ] tsql=tsql+[ padl(allt(x.transid),9) as ptransid, y.name as acname] tsql=tsql+[ from ("]+dbclocation+'invoice.dbf'+[") x left join ("]+dbclocation+'accounts.dbf'+[") y ] tsql=tsql+[ on (x.customer=y.accountid) order by vtr desc, ptransid desc ] tsql=tsql+[ where allt(transid)==']+allt(m_transid)+[' into cursor xtmpcur] endif &tsql SCATTER NAME SearchResults if TYPE('SearchResults.fbrinv')='C' and not ALLTRIM(SearchResults.fbrinv)=='0' and not EMPTY(SearchResults.fbrinv) fbrnumberreceived=allt(searchresults.fbrinv) else fbrnumberreceived=[] endif if empty(date) thedatestring=date() &&transform(date()) else thedatestring=date &&transform(dtoc(date)) endif openingbalance=[] if BETWEEN(val(left(SearchResults.customer,2)),1,8) and left(SearchResults.customer,3)<>'019' select sum(debit-credit) as dayopening from (dbclocation+[acctran]) where accountid=SearchResults.customer and date]+ALLTRIM(accounts.name)+[] =SEEK(SearchResults.customer,[accounts],[accountid]) cdebitor=[] *invnum=allt(searchresults.transid) if empty(m_transid) invnum=allt(searchresults.transid) else invnum=allt(m_transid) endif *CLOSE TABLES *CLOSE DATABASES lgetunit=iif(xcompany.zunit or xcompany.usekglibs,.t.,.f.) ************* haskglibs=xcompany.usekglibs uniquealias=SYS(2015) *uniquefilename=addbs(oprop.appstartpath)+[temp\]+uniquealias+[.dbf] IF NOT EMPTY(xcompany.fbrposid) tsql=[Select d.name as deposited,x.customer as depositid, d.phone as custphone, x.opt, x.Total As PrdTotal, x.fbrinv, x.fbrPOST, 0 as daysrno, x.discount As prdDisc, 0 as memdisc, ] tsql=tsql+[0 as TAXPRATE, 0 as TAXRATE,a.extra, x.Payment, x.EXPAMT, x.transid, x.name As Memo,Space(9) As bill, ] tsql=tsql+[x.Date,x.ddate,x.address1,x.address2,x.SaleMan,x.customer, ]+iif(lgetunit=.t.,'z.unit','0')+[ as zunit, ] + iif(xcompany.zctn=.t.,'z.ctn','space(2)')+[ as zctn, ] tsql=tsql+[space(6) as ySaleman, Y.ac,Y.Name,Y.phone, Y.fax,y.accountid, ]+ iif(xcompany.ismedical=.t.,'z.pdisc1','0')+[ as pdisc1, ] tsql=tsql+iif(xcompany.ismedical=.t.,'z.pdisc2','0')+[ as pdisc2, ] tsql=tsql+[z.ItemID, z.Batch, z.Desc, z.sr_no, z.packing, z.qty,]+iif(haskglibs,'a.kgs','0')+[ as kgs,]+iif(haskglibs,'a.libs','0')+[ as libs,z.bonus,z.rate,a.cost, a.trade ,x.dtime,0 as srvchgs, z.discount, z.Total, z.expiry ] tsql=tsql+[FROM (']+dbclocation+[invoice') x LEFT join (']+dbclocation+[ACCOUNTS') Y ON (x.customer=y.accountid) ] tsql=tsql+[LEFT JOIN (']+dbclocation+[invdata') z ON (x.transid=z.transid) LEFT join (']+dbclocation+[itemmast') a ON (z.itemid=a.itemid) ] tsql=tsql+[LEFT JOIN (']+dbclocation+[accounts') d ON (x.customer=d.accountid) ] tsql=tsql+[WHERE x.transid==']+invnum+[' Order By z.transid, x.Date, z.sr_no INTO cursor (']+uniquealias+[') readwrite] &tsql ELSE tsql=[Select d.name as deposited,x.customer as depositid, d.phone as custphone, x.opt, x.Total As PrdTotal, '' as fbrinv, '' as fbrPOST, 0 as daysrno, x.discount As prdDisc, 0 as memdisc, ] tsql=tsql+[0 as TAXPRATE, 0 as TAXRATE,a.extra, x.Payment, x.EXPAMT, x.transid, x.name As Memo,Space(9) As bill, ] tsql=tsql+[x.Date,x.ddate,x.address1,x.address2,x.SaleMan,x.customer, ]+iif(lgetunit=.t.,'z.unit','0')+[ as zunit, ] + iif(xcompany.zctn=.t.,'z.ctn','space(2)')+[ as zctn, ] tsql=tsql+[space(6) as ySaleman, Y.ac,Y.Name,Y.phone, Y.fax,y.accountid, ]+ iif(xcompany.ismedical=.t.,'z.pdisc1','0')+[ as pdisc1, ] tsql=tsql+iif(xcompany.ismedical=.t.,'z.pdisc2','0')+[ as pdisc2, ] tsql=tsql+[z.ItemID, z.Batch, z.Desc, z.sr_no, z.packing, z.qty,]+iif(haskglibs,'a.kgs','0')+[ as kgs,]+iif(haskglibs,'a.libs','0')+[ as libs,z.bonus,z.rate,a.cost, a.trade ,x.dtime,0 as srvchgs, z.discount, z.Total, z.expiry ] tsql=tsql+[FROM (']+dbclocation+[invoice') x LEFT join (']+dbclocation+[ACCOUNTS') Y ON (x.customer=y.accountid) ] tsql=tsql+[LEFT JOIN (']+dbclocation+[invdata') z ON (x.transid=z.transid) LEFT join (']+dbclocation+[itemmast') a ON (z.itemid=a.itemid) ] tsql=tsql+[LEFT JOIN (']+dbclocation+[accounts') d ON (x.customer=d.accountid) ] tsql=tsql+[WHERE x.transid==']+invnum+[' Order By z.transid, x.Date, z.sr_no INTO cursor (']+uniquealias+[') readwrite] &tsql endif select (uniquealias) thedeposited=nvl(deposited,'') =changeFieldStruc() IF EMPTY(memo) AND depositid<>[019] *replace ALL memo WITH thedeposited ENDIF go top thevendordetails=allt(depositid)+[: ]+allt(thedeposited)+[ ]+allt(custphone) XDISCLABEL=[] rept_saleman=[] hastax=.f. hasdiscount=.f. haszunit = .f. haszctn = .f. haskglibs=xcompany.usekglibs Go Top haspdisc1=.f. haspdisc2=.f. hasbonus=.f. hasexpiry=.f. hasbatch=.f. select (uniquealias) SCAN if not empty(kgs) or not empty(libs) haskglibs=xcompany.usekglibs endif if not empty(expiry) hasexpiry=.t. endif if not empty(batch) hasbatch=.t. endif if not empty(pdisc1) haspdisc1=.t. endif if not empty(pdisc2) haspdisc2=.t. endif if not empty(bonus) hasbonus=.t. endif if not empty(zunit) haszunit= .t. endif if not empty(zctn) haszctn= .t. endif if not empty(taxprate) or not empty(taxrate) hastax=.t. endif replace cost WITH NVL(cost,0), trade WITH NVL(trade,0), sr_no WITH RECNO() IF discount<>0 XDISCLABEL=[DISC] hasdiscount=.t. ENDIF IF NOT EMPTY(saleman) rept_saleman=IIF(SEEK(saleman,[accounts],[accountid]),accounts.name,[]) endif theuser=allt(opt) endscan If xcompany.haspart PartsValue=0 partsQty=0 Select (uniquealias) Go Top Scan If Seek(ItemID,'itemmast','itemid') And itemmast.ispart PartsValue=PartsValue+(rate*qty-discount) partsQty=partsQty+qty Scatter Name saveit Delete ENDIF IF discount<>0 XDISCLABEL=[DISC] endif Endscan If PartsValue<>0 Append Blank Gather Name saveit Replace Desc With 'REPAIR CHARGES',; qty With partsQty,; rate With (PartsValue)/partsQty,; total With PartsValue Endif Endif go top STORE 0 TO TOTALTAX, fbrservice, SERVICECHARGES, TOTALAMOUNT, PRODUCTDISCOUNT,; MEMBERDISCOUNT, NETAMOUNT, RECEIVEDAMOUNT, BALANCEAMOUNT IF type([searchresults.fbrinv])=[C] and not empty(searchresults.fbrinv) fbrservice=1 endif SERVICECHARGES=srvchgs TOTALAMOUNT=ROUND(prdtotal+srvchgs,0) PRODUCTDISCOUNT=prdDisc MEMBERDISCOUNT=memdisc netamount=ROUND(prdtotal+fbrservice-prdDISC-MEMDISC+srvchgs,0) RECEIVEDAMOUNT=iif(empty(payment),netamount,payment) BALANCEAMOUNT=RECEIVEDAMOUNT-netamount select (uniquealias) ************* %>

<%=xcompany.name%><%=iif(empty(xcompany.ntn),'',[NTN: ]+allt(xcompany.ntn))%>

<%=allt(allt(xcompany.address1)+[ ]+allt(xcompany.address2))%> <%=allt(allt(xcompany.phone)+[ ]+allt(xcompany.email))%>

CLIENT:

<%=thevendordetails%>

<%if hasbatch%> <%endif%> <%if hasexpiry%> <%endif%> <%if haskglibs%> <%else%> <%if haszctn%> <%endif%> <%if haszunit%> <%endif%> <%if hasbonus%> <%endif%> <%endif haskglibs%> <%if hastax=.t.%> <%endif%> <%if haspdisc1%> <%endif%> <%if haspdisc2%> <%endif%> <%if hasdiscount%> <%endif%> <%SCAN%> <% select (uniquealias) ITEMTX=round(iif(empty(taxprate),taxrate*qty,(qty*rate)-(qty*rate)/(1+taxprate/100)),2) if empty(taxprate) thetaxprate=round((taxrate/(rate-taxrate))*100,2) else thetaxprate=taxprate endif SALEINCLUDINGTAX=qty*rate saleexcludingtax=saleincludingtax-itemtx totaltax=totaltax+itemtx thechars=[] textra=allt(nvl(extra,'')) if not empty(textra) for i=1 to len(textra) thechars=thechars+[ | ]+subst(textra,i,1)+[ : ]+transform(asc(subst(textra,i,1))) endfor endif testunits=nvl(zunit,0) kgqty=QTY*iif(KGS=0,1,kgs) libsqty=QTY*iif(libs=0,2.20462,libs) kgqty=icase(kgqty=round(kgqty,0),round(kgqty,0),kgqty=round(kgqty,2),round(kgqty,2),kgqty=round(kgqty,3),round(kgqty,3),round(kgqty,4)) libsqty=icase(libsqty=round(libsqty,0),round(libsqty,0),libsqty=round(libsqty,2),round(libsqty,2),libsqty=round(libsqty,3),round(libsqty,3),round(libsqty,4)) rateperlib=saleexcludingtax/libsqty if haskglibs if empty(kgs) thectnqty=iif(empty(testunits),qty,testunits) else thectnqty=qty endif rateperkg=saleexcludingtax/kgqty else thectnqty=qty *rateperkg=saleexcludingtax/qty rateperkg=saleincludingtax/qty endif rateperkg=icase(rateperkg=round(rateperkg,0),round(rateperkg,0),round(rateperkg,2)) rateperlib=icase(rateperlib=round(rateperlib,0),round(rateperlib,0),round(rateperlib,2)) %> <%if hasbatch%> <%endif%> <%if hasexpiry%> <%endif%> <%if haskglibs%> <%else%> <%if haszctn%> <%endif%> <%if haszunit%> <%endif%> <%if hasbonus%> <%endif%> <%endif haskglibs%> <%if hastax=.t.%> <%endif%> <% roundeddisc=icase(discount=round(discount,0),round(discount,0),round(discount,2)) %> <%if haspdisc1%> <%endif%> <%if haspdisc2%> <%endif%> <%if hasdiscount%> <%endif%> <%ENDSCAN%> <% cspan=1 %> <%if not empty(openingbalance)%>

DEBIT SALES

<%if not empty(fbrnumberreceived)%>

<%endif%> <%if type([searchresults.fbrinv])=[C] and not empty(searchresults.fbrinv)%>

<%=[POSID# ]+ALLT(xcompany.fbrposid)%> <%=[FBR# ]+ALLT(fbrinv)%>

<%endif%> <%if not empty(memo)%>

<%=allt(memo)%>

<%endif%>

<%=[PUR# ]+ALLT(TRANSID)+[ DATE: ]+dtoc(date)+iif(empty(bill),[],[ BILL: ]+allt(bill))%>

# DETAILSBatchexpiryKGs LIBs CTNs RATE/LIB RATE/KGUNITPCSQTYBONUSRATETAX VATTOTALDisc
ON Sale
Disc
NET
DISC NET AMOUNT
<%=RECNO()%> <%=icase(isurdu=2,allt(DESC)+iif(empty(textra),[],[
]+allt(textra)),isurdu=1,iif(empty(textra),allt(desc),allt(textra)),allt(desc))%>
<%=iif(empty(batch),' ',transform(batch))%><%=iif(empty(expiry),' ',transform(expiry))%><%=iif(empty(KGQTY),' ',KGQTY)%> <%=iif(empty(libsQTY),' ',libsQTY)%> <%=iif(empty(thectnqty),' ',thectnqty)%> <%=iif(empty(rateperlib),' ',rateperlib)%> <%=iif(empty(rateperkg),' ',rateperkg)%><%=zctn%><%=iif(empty(thectnqty),' ',thectnqty)%><%=thectnqty%><%=iif(empty(bonus),' ',transform(bonus))%><%=rateperkg%><%=iif(empty(thetaxprate),' ',transform(thetaxprate)+[%])%> <%=iif(empty(itemtx),' ',transform(itemtx,'999999999.99'))%><%=ROUND(qty*rate,0)%><%=iif(empty(pdisc1),' ',transform(pdisc1)+'%')%><%=iif(empty(pdisc2),' ',transform(pdisc2)+'%')%><%=iif(empty(roundeddisc),' ',transform(roundeddisc))%> <%=ROUND(qty*rate-roundeddisc,0)%>
<%if hastax=.t.%> <%if totaltax<>0 %> <%endif%> <%endif%> <%if fbrservice<>0 %> <%endif%> <%if SERVICECHARGES<>0 %> <%endif%> <%if round(PRODUCTDISCOUNT+MEMBERDISCOUNT,2)<>0 %> <%endif%>
TOTAL TAX<%=transform(TOTALTAX,'99999999999999.99')%>
POS SERVICE CHARGES<%=transform(fbrservice,'99999999999999.99')%>
SERVICE CHARGES<%=transform(SERVICECHARGES,'99999999999999.99')%>
TOTAL AMOUNT<%=transform(TOTALAMOUNT+fbrservice+SERVICECHARGES,'99999999999999.99')%>
DISCOUNT<%=transform(PRODUCTDISCOUNT+MEMBERDISCOUNT,'99999999999999.99')%>
NET AMOUNT<%=transform(TOTALAMOUNT+fbrservice+SERVICECHARGES-PRODUCTDISCOUNT-MEMBERDISCOUNT,'99999999999999.99')%>
<%if not empty(nvl(closing.debits,0))%> <%endif%> <%if not empty(nvl(closing.Credits,0))%> <%endif%>
Opening<>
Add Debits<>
Less Credits<>
Closing Balance<>
<%endif%>
<% LASTMESSAGE=[] IF NOT EMPTY(XCOMPANY.CUSTMSG1) LASTMESSAGE=LASTMESSAGE+ALLT(XCOMPANY.CUSTMSG1)+[ ] ENDIF IF NOT EMPTY(XCOMPANY.CUSTMSG2) LASTMESSAGE=LASTMESSAGE+ALLT(XCOMPANY.CUSTMSG2)+[ ] ENDIF IF NOT EMPTY(XCOMPANY.CUSTMSG3) LASTMESSAGE=LASTMESSAGE+ALLT(XCOMPANY.CUSTMSG3)+[ ] ENDIF IF NOT EMPTY(XCOMPANY.CUSTMSG4) LASTMESSAGE=LASTMESSAGE+ALLT(XCOMPANY.CUSTMSG4)+[ ] ENDIF %>

<%='OPERATOR '+ALLT(theuser)+' '+IIF(EMPTY(REPT_SALEMAN),'','SOLD BY: '+REPT_SALEMAN)%>

<%if NOT EMPTY(LASTMESSAGE) %>

<%=LASTMESSAGE%>

<%endif%>
<% CLOSE TABLES CLOSE DATABASES USE IN SELECT(uniquealias) clear resources %>